<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <!-- <el-form-item label="主表id" prop="mainId">
        <el-input
          v-model="queryParams.mainId"
          placeholder="请输入主表id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="人物名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入人物名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <!-- <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['figureInclusion:figureInclusion:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['figureInclusion:figureInclusion:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['figureInclusion:figureInclusion:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['figureInclusion:figureInclusion:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row> -->

    <el-table
      v-loading="loading"
      :data="figureInclusionList"
      @selection-change="handleSelectionChange"
    >
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <!-- <el-table-column label="主表id" align="center" prop="mainId" /> -->
      <el-table-column label="人物头像图" align="center" prop="headImgUrl">
        <template v-slot:default="scope">
          <el-image
            style="width: 100px; height: 100px"
            :src="imageUrl + scope.row.headImgUrl"
            fit="cover"
          ></el-image>
        </template>
      </el-table-column>
      <el-table-column label="人物名称" align="center" prop="name" />
      <!-- <el-table-column label="基本介绍" align="center" prop="content" /> -->
      <!-- <el-table-column
        label="工作经历id(项目和机构)"
        align="center"
        prop="workExpId"
      />
      <el-table-column label="教育经历" align="center" prop="educationExp" /> -->
      <!-- <el-table-column label="语言类型" align="center" prop="lang"  /> -->
      <el-table-column label="审核状态" align="center" prop="exStatus" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-search"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['figureInclusion:figureInclusion:edit']"
            >查看</el-button
          >
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['figureInclusion:figureInclusion:remove']"
            >删除</el-button
          > -->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改人物收录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="100px"
        :disabled="true"
      >
        <el-form-item label="人物头像图" prop="headImgUrl">
          <el-image
            style="width: 100px; height: 100px"
            :src="imageUrl + form.headImgUrl"
            fit="cover"
          ></el-image>
        </el-form-item>
        <el-form-item label="人物名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入人物名称" />
        </el-form-item>
        <el-form-item label="基本介绍">
          <el-input :rows="10" v-model="form.content" type="textarea" />
        </el-form-item>
        <el-form-item label="教育经历" prop="educationExp">
          <el-input v-model="form.educationExp" type="textarea" />
        </el-form-item>

        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" />
        </el-form-item>
        <el-form-item label="工作经历" prop="workExperienceList">
          <el-table :data="form.workExperienceList" style="width: 100%">
            <el-table-column prop="remark" label="名称" width="180">
            </el-table-column>
            <el-table-column prop="post" label="岗位" width="180">
            </el-table-column>
            <el-table-column prop="time" label="工作时间"> </el-table-column>
          </el-table>
        </el-form-item>

        <el-form-item label="社媒链接" prop="smcList">
          <el-table :data="form.smcList" style="width: 100%">
            <el-table-column prop="webType" label="名称" width="180">
            </el-table-column>
            <el-table-column prop="webUrl" label="链接"> </el-table-column>
          </el-table>
        </el-form-item>

        <el-form-item label="对外投资" prop="investDetailsList">
          <el-table :data="form.investDetailsList" style="width: 100%">
            <el-table-column prop="projectName" label="项目名" width="150">
            </el-table-column>
            <el-table-column prop="round" label="轮次" width="60">
            </el-table-column>
            <el-table-column prop="amount" label="金额" width="150">
            </el-table-column>
            <el-table-column prop="valuation" label="估值"> </el-table-column>
            <el-table-column prop="time" label="时间"> </el-table-column>
            <!-- <el-table-column
              prop="ledStatus"
              label="领投"
              :formatter="ledFormate"
            >
            </el-table-column> -->
            <!-- <el-table-column prop="investor" label="投资方"> </el-table-column> -->
            <!-- <el-table-column prop="link" label="链接"> </el-table-column> -->
          </el-table>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listFigureInclusion,
  getFigureInclusion,
  getUniversityInformation,
  delFigureInclusion,
  addFigureInclusion,
  updateFigureInclusion,
} from "@/api/figureInclusion/figureInclusion";
import { imageUrl } from "@/config";
export default {
  name: "FigureInclusion",
  data() {
    return {
      imageUrl,
      // 遮罩层
      loading: true,

      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 人物收录表格数据
      figureInclusionList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        mainId: null,
        headImgUrl: null,
        name: null,
        content: null,
        workExpId: null,
        educationExp: null,
        lang: null,
      },
      // 表单参数
      form: {
        school: "",
      },
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询人物收录列表 */
    getList() {
      this.loading = true;
      listFigureInclusion(this.queryParams).then((response) => {
        this.figureInclusionList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        mainId: null,
        headImgUrl: null,
        name: null,
        content: null,
        workExpId: null,
        educationExp: null,
        lang: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加人物收录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getFigureInclusion(id).then((response) => {
        this.form = response.data;

        this.open = true;
        this.title = "查看人物收录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateFigureInclusion(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addFigureInclusion(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除人物收录编号为"' + ids + '"的数据项？')
        .then(function () {
          return delFigureInclusion(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "figureInclusion/figureInclusion/export",
        {
          ...this.queryParams,
        },
        `figureInclusion_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
